package com.ease.business.systemmonitor.util;

import java.util.HashMap;

public class MapUtil {

	public static String getStr(HashMap<?, ?> map, String key, String defaultValue) {
		Object object = map.get(key);
		if (object == null)
			return defaultValue;
		return object.toString();
	}

	public static String getStr(HashMap<?, ?> map, String key) {
		return getStr(map, key, null);
	}

	public static int getInt(HashMap<?, ?> map, String key, int defaultValue) {
		String value = getStr(map, key, defaultValue + "");
		return Integer.parseInt(value);
	}

	public static int getInt(HashMap<?, ?> map, String key) {
		return getInt(map, key, 0);
	}

	public static long getLong(HashMap<?, ?> map, String key, long defaultValue) {
		String value = getStr(map, key, defaultValue + "");
		return Long.parseLong(value);
	}
}
